import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { NoticeNewsVO, NoticeNewsForm, NoticeNewsQuery } from '@/api/business/noticeNews/types';

/**
 * 查询检察要闻列表
 * @param query
 * @returns {*}
 */

export const listNoticeNews = (query?: NoticeNewsQuery): AxiosPromise<NoticeNewsVO[]> => {
  return request({
    url: '/business/noticeNews/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询检察要闻详细
 * @param baseId
 */
export const getNoticeNews = (baseId: string | number): AxiosPromise<NoticeNewsVO> => {
  return request({
    url: '/business/noticeNews/' + baseId,
    method: 'get'
  });
};

/**
 * 新增检察要闻
 * @param data
 */
export const addNoticeNews = (data: NoticeNewsForm) => {
  return request({
    url: '/business/noticeNews',
    method: 'post',
    data: data
  });
};

/**
 * 修改检察要闻
 * @param data
 */
export const updateNoticeNews = (data: NoticeNewsForm) => {
  return request({
    url: '/business/noticeNews',
    method: 'put',
    data: data
  });
};

/**
 * 删除检察要闻
 * @param baseId
 */
export const delNoticeNews = (baseId: string | number | Array<string | number>) => {
  return request({
    url: '/business/noticeNews/' + baseId,
    method: 'delete'
  });
};

/**
 * 是否展示
 */
export const visibleChange = (baseIds: Array<string | number>, status: boolean) => {
  return request({
    url: '/business/noticeNews/visible',
    method: 'post',
    data: {
      baseIds: baseIds,
      status: status
    }
  });
};
/**
 * 审核
 */
export const auditChange = (baseIds: Array<string | number>, status: boolean, reason: string) => {
  return request({
    url: '/business/noticeNews/audit',
    method: 'post',
    data: {
      baseIds: baseIds,
      status: status,
      reason: reason
    }
  });
};
/**
 * 轮播
 */
export const doCarousel = (baseIds: Array<string | number>, status: boolean) => {
  return request({
    url: '/business/noticeNews/doCarousel',
    method: 'post',
    data: {
      baseIds: baseIds,
      status: status
    }
  });
};
